"; // echo ""; if (array_key_exists('submit', $_POST)) { //define variables $subj = trim($_POST['subject']); $acyear = trim($_POST['acyear']); $schterm = trim($_POST['acterm']); $classid = trim($_POST['classid']); // $high = trim($_POST['high']); // $low = trim($_POST['low']); // $caverage = trim($_POST['average']); // mysql_select_db("$database", $conn); $res = mysql_query("SELECT subject_id , subjectname FROM subjects where subjectname = '$subj' "); $row1 = mysql_fetch_assoc($res) ; $resultid = $row1['subject_id'] ; $fp = fopen($_FILES["images"]["tmp_name"], "r"); while ($line = fgets($fp)) { // Loop through each line list ($regno ,$first, $exam) = explode("\t", $line, 3); // Split the line by the tab delimiter and store it in our list $sql = "insert into marks (stregno,acad_session,term,subject_id,stclass,firsttest,exam) values ('$regno' , '$acyear','$schterm', '$resultid', '$classid', '$first', '$exam' )" ; // Generate our sql string $result = mysql_query($sql) or die(mysql_error()); } if (isset($result)) $message = 'Result Uploaded Succesfully' ; } ?>